package com.ruix.app.model;

import android.text.TextUtils;

import org.json.JSONObject;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by hadexs on 2017/7/19.
 */

public class PurseRecord {
    private int amount;
    private String title;
    private long createdTime;
    private String type;


    public PurseRecord parse(JSONObject object){
        if (object != null){
            title =  object.optString("title","");
            type=  object.optString("type","");
            amount=  object.optInt("amount",0);
            createdTime =  object.optLong("created_at",0) * 1000;
        }

        return this;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public long getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(long createdTime) {
        this.createdTime = createdTime;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String displayTime(){
        Date date = new Date(createdTime);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        return sdf.format(date);
    }

    public String moneyString(){
        double abc = amount / 100.0;
        DecimalFormat df = new DecimalFormat("#0.00");
        return df.format(abc);
    }
}
